#import "sybase_sup.h"
#import "SUPAnnotations.h"

#import "SUPAbstractDB.h"
@class smMboPersonalizationParameters;
#import "smMboSynchronizationGroup.h"

// Entity metadata definitions (for internal use)
#ifndef _ENTITY_NUMBERS_FOR_smMboSmMboDB_
#define _ENTITY_NUMBERS_FOR_smMboSmMboDB_
#define _ENTITY_NUMBER_FOR_smMboContractSeq_ 1
#define _ENTITY_NUMBER_FOR_smMboHouseSeq_ 2
#define _ENTITY_NUMBER_FOR_smMboImageSeq_ 3
#define _ENTITY_NUMBER_FOR_smMboOrderSeq_ 4
#define _ENTITY_NUMBER_FOR_smMboPaymentSeq_ 5
#define _ENTITY_NUMBER_FOR_smMboProjectSeq_ 6
#define _ENTITY_NUMBER_FOR_smMboSmTbContract_ 7
#define _ENTITY_NUMBER_FOR_smMboSmTbHouse_ 8
#define _ENTITY_NUMBER_FOR_smMboSmTbImage_ 9
#define _ENTITY_NUMBER_FOR_smMboSmTbOrder_ 10
#define _ENTITY_NUMBER_FOR_smMboSmTbPayment_ 11
#define _ENTITY_NUMBER_FOR_smMboSmTbProject_ 12
#define _ENTITY_NUMBER_FOR_smMboSmTbUser_ 13
#define _ENTITY_NUMBER_FOR_smMboUserSeq_ 14
#define _ENTITY_NUMBER_FOR_smMboLogRecordImpl_ 15
#endif //_ENTITY_NUMBERS_FOR_smMboSmMboDB_
// End entity metadata definitions


@class SUPLogRecord;

// public interface declaration, can be used by application. 
/*!
 @class smMboSmMboDB
 @abstract This class is part of package "smMbo:1.0"
 @discussion Generated by Sybase Unwired Platform, compiler version 2.1.2.109
*/ 
@interface smMboSmMboDB : SUPAbstractDB
{
@private
    
}
/*!
  @method 
  @abstract Returns the personalization parameters for this package
  @discussion
  @throws SUPPersistenceException
 */
+ (smMboPersonalizationParameters*)getPersonalizationParameters;

/*!
  @method 
  @abstract Returns the callback handler for the database class.
  @discussion
 */
+ (NSObject<SUPCallbackHandler>*)callbackHandler;
/*!
  @method 
  @abstract Returns the connection profile.
  @discussion
 */
+ (SUPConnectionProfile*)connectionProfile;
/*!
  @method 
  @abstract Returns the connection profile.
  @discussion
 */
+ (SUPConnectionProfile*)getConnectionProfile;
/*!
  @method 
  @abstract Returns the synchronization profile.
  @discussion
 */
+ (SUPConnectionProfile*)getSynchronizationProfile;
/*!
  @method 
  @abstract Creates the database and initializes the tables for all MBOs in this package.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)createDatabase;
/*!
  @method 
  @abstract Drop all data from all tables: if keepClientOnly = YES, do not drop data from client-only tables.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)cleanAllData:(BOOL) keepClientOnly;
/*!
  @method 
  @abstract Drop all data from all tables, except client-only tables.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)cleanAllData;
/*!
  @method 
  @abstract Deletes the database for this package.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)deleteDatabase;
/*!
  @method 
  @abstract Return true if database exists, false otherwise.
  @discussion
 */
+ (BOOL)databaseExists;
/*!
  @method 
  @abstract Return the database connection for this package.
  @discussion
 */
+ (id<SUPConnectionWrapper>)getConnectionWrapper;
/*!
  @method 
  @abstract Opens database connection.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)openConnection;
/*!
  @method 
  @abstract Closes database connection.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)closeConnection;
/*!
  @method 
  @abstract Return the username used in communcations with server.
  @discussion
 */
+ (NSString*)getSyncUsername;
/*!
  @method 
  @abstract Return the package name.
  @discussion
 */
+ (NSString*)getPackageName;
/*!
  @method 
  @abstract Return the current server domain name.
  @discussion
 */
+ (NSString*)getDomainName;
/*!
  @method 
  @abstract Return the database schema version of this package.
  @discussion
 */
+ (int32_t)getSchemaVersion;
/*!
  @method 
  @abstract Return the protocol version of this package.
  @discussion
 */
+ (int32_t)getProtocolVersion;
/*!
  @method 
  @abstract Return the logger for this package.
  @discussion
 */
+ (id<SUPLogger>)getLogger;
/*!
  @method 
  @abstract Return current login status: SUPLoginPending, SUPLoginFailure, or SUPLoginSuccess.
  @discussion
 */
+ (SUPOnlineLoginStatus*)getOnlineLoginStatus;
/*!
  @method 
  @abstract Return a list of all synchronization groups defined for the package.
  @discussion
 */
+ (SUPObjectList*)getAllSynchronizationGroups;
/*!
  @method 
  @abstract Return a list of the synchronization groups corresponding to the given list of group names.
  @discussion
 */
+ (SUPObjectList*)getSynchronizationGroups:(SUPStringList*)groupNames;
/*!
  @method 
  @abstract Execute the passed in query and return a result set.
  @discussion
  @throws SUPPersistenceException
 */
+ (SUPQueryResultSet*)executeQuery:(SUPQuery*)query;
/*!
  @method 
  @abstract Set the callback handler for the database class.
  @discussion
 */
+ (void)registerCallbackHandler:(NSObject<SUPCallbackHandler>*)handler;

/*!
  @method 
  @abstract Set Application instance.
  @discussion
 */
+ (void)setApplication:(SUPApplication*)application;
/*!
  @method 
  @abstract Validate this user and password with the server (synchronous method). Deprecated.
  @discussion
  @throws NSException
 */
+ (void)loginToSync:(NSString *)user password:(NSString *)pass DEPRECATED_ATTRIBUTE;
/*!
  @method 
  @abstract Validate this user and password with the server (asynchronous method).
  @discussion
 */
+ (void)beginOnlineLogin:(NSString *)user password:(NSString *)pass;
/*!
  @method 
  @abstract Validate with the server, assuming sync profile already set up with username/password or SSO certificate.
  @discussion
 */
+ (void)beginOnlineLogin;
/*!
  @method 
  @abstract Validate this user and password with the device database (after a successful online login) -- returns true if username/password is valid.
  @discussion
 */
+ (BOOL)offlineLogin:(NSString *)user password:(NSString *)pass;
/*!
  @method 
  @abstract Validate with the device database (after a successful online login) -- returns true if username/password or SSO certificate is valid.
  @discussion
 */
+ (BOOL)offlineLogin;
/*!
  @method 
  @abstract Resume the subscription to the server after a call to suspendSubscription.
  @discussion
 */
+ (void)resumeSubscription;
/*!
  @method 
  @abstract Subscribe to the server.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)subscribe;
/*!
  @method 
  @abstract Send a message to the server to synchronize this client with all groups in the package.
  @discussion
 */
+ (void)beginSynchronize;
/*!
  @method 
  @abstract (Deprecated) Send a message to the server to synchronize this client with the specified synchronization groups.
  @discussion
 */
+ (void)beginSynchronize:(NSString*)synchronizationGroups:(NSString*)context DEPRECATED_ATTRIBUTE;
/*!
  @method 
  @abstract Send a message to the server to synchronize this client with the specified synchronization groups.
  @discussion
 */
+ (void)beginSynchronize:(SUPObjectList*)synchronizationGroups withContext:(NSString*)context;
/*!
  @method 
  @abstract Search through all entities in this package and send any pending changes to the server.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)submitPendingOperations;
/*!
  @method 
  @abstract Search through all entities in this package for the given synchronization group and send any pending changes to the server.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)submitPendingOperations:(NSString*)synchronizationGroup;
/*!
  @method 
  @abstract Search through all entities in this package and cancel any pending changes.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)cancelPendingOperations;
/*!
  @method 
  @abstract Search through all entities in this package for the given synchronization group and cancel any pending changes.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)cancelPendingOperations:(NSString*)synchronizationGroup;
/*!
  @method 
  @abstract return TRUE if there are replay pending requests, false otherwise.
  @discussion
 */
+ (BOOL)hasPendingOperations;
/*!
  @method 
  @abstract Suspend the current server subscription.
  @discussion
 */
+ (void)suspendSubscription;
/*!
  @method 
  @abstract Send the recover message to the server to have it send all the current data for this client.
  @discussion
 */
+ (void)recover;
/*!
  @method 
  @abstract End the current subscription to the server.
  @discussion
 */
+ (void)unsubscribe;
/*!
  @method 
  @abstract Returns YES if package is currently subscribed to the server, NO otherwise.
  @discussion
 */
+ (BOOL)isSubscribed;

/*!
  @method 
  @abstract Generate a new encryption key.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)generateEncryptionKey;
/*!
  @method 
  @abstract Change the encryption key used for database encryption.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)changeEncryptionKey:(NSString *)newKey;
/*!
  @method 
  @abstract Return log records matching the passed in query.
  @discussion
  @throws SUPPersistenceException
 */
+ (SUPObjectList*)getLogRecords:(SUPQuery*)query;
/*!
  @method 
  @abstract Submit any pending client-created log records to the server.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)submitLogRecords;
/*!
  @method 
  @abstract Execute VACUUM on database to clean up internal database structure.
  @discussion
  @throws SUPPersistenceException
 */
+ (void)vacuum;


@end



// internal methods declaration, only used by generated code.
@interface smMboSmMboDB(internal)
+ (SUPReadWriteLock*)dblock;
+ (SUPLocalTransaction*)beginTransaction;
+ (smMboSmMboDB*)instance;
+ (void)replay:(NSString *)mbo withId:(int64_t)counter withContent:(SUPJsonArray*)content;
+ (void)search:(NSString *)mbo withId:(int64_t)counter withContent:(SUPJsonArray*)content;
+ (void)replay:(NSString *)mbo withId:(int64_t)counter withContentStream:(SUPJsonInputStream*)stream;
+ (void)search:(NSString *)mbo withId:(int64_t)counter withContentStream:(SUPJsonInputStream*)stream;
+ (SUPQueryResultSet*)executeQuery:(SUPDatabaseMetaData*)metaData query:(SUPQuery*)query;
+ (void)onMessage:(SUPJsonMessage*)message;
+ (id<SUPQueueConnection>)queueConnection;
+ (void)checkIfSubscribed;
+ (BOOL)packageHasSubscription;
+ (void)clearConnection;
+ (BOOL)onlineLogin;
+ (void)setNeedSync;
+ (void)synchronizeIfNeeded;
+ (void)storeCredential:(NSString *)user passwordHash:(NSUInteger)passHash;
+ (void)synchronize;
+ (smMboSynchronizationGroup*)getSyncGroupForName:(NSString*)_name;
@end